//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Resource Application Block
//===============================================================================

using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Management.Instrumentation;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Manageability;

namespace EntLibContrib.Resource.Configuration.Manageability
{
	/// <summary>
	/// Represents the configuration information from a 
	/// <see cref="EntLibContrib.Resource.Configuration.BinaryResourceProviderData"/> instance.
	/// </summary>
	/// <seealso cref="EntLibContrib.Resource.Configuration.BinaryResourceProviderData"/>
	/// <seealso cref="ResourceProviderSetting"/>
	[ManagementEntity]
	public class BinaryResourceProviderSetting : ResourceProviderSetting
	{
		#region Fields
		private string resourcePathName;
		#endregion

		#region Properties
		/// <summary>
		/// Gets the name of the path for the represented configuration object.
		/// </summary>
		/// <value>The name of the resource path.</value>
		/// <seealso cref="EntLibContrib.Resource.Configuration.BinaryResourceProviderData.ResourcePathName">BinaryResourceProviderData.ResourcePathName</seealso>
		[ManagementProbe]
		public string ResourcePathName
		{
			get { return resourcePathName; }
			set { resourcePathName = value; }
		}
		#endregion

		#region Construction
		/// <summary>
		/// Initializes a new instance of the <see cref="BinaryResourceProviderSetting"/> class.
		/// </summary>
		/// <param name="name">The name.</param>
		/// <param name="resourcePathName">Name of the resource path.</param>
		/// <param name="resourceBaseName">Name of the resource base.</param>
		public BinaryResourceProviderSetting(string name, string resourcePathName, string resourceBaseName)
			: base(name, resourceBaseName)
		{
			this.resourcePathName = resourcePathName;
		}
		#endregion

		#region Public Static Methods
		/// <summary>
		/// Returns an enumeration of the published <see cref="BinaryResourceProviderSetting"/> instances.
		/// </summary>
		[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate"), ManagementEnumerator]
		public static IEnumerable<BinaryResourceProviderSetting> GetInstances()
		{
			return NamedConfigurationSetting.GetInstances<BinaryResourceProviderSetting>();
		}

		/// <summary>
		/// Returns the <see cref="BinaryResourceProviderSetting"/> instance corresponding to the provided values for the key properties.
		/// </summary>
		/// <param name="applicationName">Name of the application.</param>
		/// <param name="sectionName">Name of the section.</param>
		/// <param name="name">The name.</param>
		/// <returns>
		/// The published <see cref="BinaryResourceProviderSetting"/> instance specified by the values for the key properties,
		/// or <see langword="null"/> if no such an instance is currently published.
		/// </returns>
		[ManagementBind]
		public static BinaryResourceProviderSetting BindInstance(string applicationName, string sectionName, string name)
		{
			return NamedConfigurationSetting.BindInstance<BinaryResourceProviderSetting>(applicationName, sectionName, name);
		}
		#endregion
	}
}
